<?php

namespace app\shop\model\product;

use app\common\model\product\ProductMark as MarkModel;

/**
 * 标记模型
 */
class ProductMark extends MarkModel
{
    
    /**
     * 添加新记录
     */
    public function add($data)
    {
        $data['app_id'] = self::$app_id;
        return $this->save($data);
    }

    /**
     * 编辑记录
     */
    public function edit($data)
    {

        $data['update_time'] = time();
        return $this->save($data);
    }

    /**
     * 删除
     */
    public function remove()
    {
        // 判断是否存在
        $Count = (new Product())->where('mark_id','=' ,$this['id'])
            ->where('product_status','=','10')
            ->where('audit_status','=','20')
            ->where('is_delete','=','0')
            ->count();
        if ($Count > 0) {
            $this->error = '该标记使用中，不允许删除';
            return false;
        }
        return $this->delete();
    }

 
}